#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
int main()
{
    pid_t id = fork();
    if(id ==0)
    {
        //子进程
        int cnt = 5;
        while(cnt)
        {
            printf("我是一个子进程，pid:%d,ppid:%d\n",getpid(),getppid());
            sleep(1);
            cnt--;
        }
        exit(0);
    }

    //父进程
    pid_t rid = wait(NULL);
    if(rid>0)
    {
        printf("wait success,rid:%d\n",rid);
    }
    sleep(10);
    return 0;
}
